package zdh.avatar.base;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * Final class that filters the audio files allowed to be used in the program.
 * 
 * @author Gem Seeker
 */
public final class AudioFileFilter extends FileFilter {
    
    @Override
    public boolean accept(File file){
        /*
         * first obtain the file extension of the file
         */
        String ext = Util.getExtension(file);
        
        /*
         * allow directories to be seen by the file chooser
         */
        if(file.isDirectory()){
            return true;
        }
        
        /*
         * allow files with extensions; au, wav, aiff
         */
        if(ext != null){
            if(ext.equals(Util.au) || ext.equals(Util.wav) || ext.equals(Util.aiff)){
                return true;
            }else{
                return false;
            }
        }
        return false;
    }
    
    @Override
    public String getDescription(){
        return "\".au\", \".wav\", \".aiff\"";
    }
    
}
